package org.example;

public class Student_Tree implements Comparable<Student_Tree> {
    private String name;
    private int age;

    public Student_Tree() {
    }

    public Student_Tree(String name, int age) {
        this.name = name;
        this.age = age;
    }
    //重写toString方法
    @Override
    public String toString() {
        return "Student_Tree{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    @Override
    public int compareTo(Student_Tree o) {
        System.out.println("this:"+this);
        System.out.println("o:"+o);
        //排序规则
        //年龄升序 this表示当前要添加对象 o表示已经存在对象
        return this.age-o.age;
    }
}
